package day18.pack7;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Student implements Cloneable {
//    public Student() {
//        System.out.println("走了构造");
//    }
//
//    public Student(String studentName, Integer id) {
//        this();
//        this.studentName = studentName;
//        this.id = id;
//    }

    private String studentName;
    private Integer id;
    private Teacher teacher;

    protected Student clone() throws CloneNotSupportedException {
        Student newStudent =  (Student) super.clone();
        // 深拷贝
        Teacher newTeacher = newStudent.getTeacher().clone();
        newStudent.setTeacher(newTeacher);
        return newStudent;
    }
}
